package com.hrprojectback.controller.KaoQinGuanLi;

import com.hrprojectback.dto.*;
import com.hrprojectback.enums.StatusEnum;
import com.hrprojectback.service.KaoQinGuanLiService.BanBieService;
import com.hrprojectback.service.XinXiGuanLiService.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.HashMap;
import java.util.List;

public class BanBieController {
    @Autowired
    private BanBieService banBieService;

    @GetMapping("/banbie")
    public ResponseDTO getBanBie(BanBieInfo banBieInfo) {
        //获取班别的总数量
        Integer banBieCounts = banBieService.getBanBieCounts(banBieInfo.getBanBieCode(), banBieInfo.getBanBieName());
        //开始页
        int pageStart = (banBieInfo.getPageNum() - 1) * banBieInfo.getPageSize();
        List<BanBie> banBies = banBieService.getBanbie(banBieInfo.getBanBieCode(), banBieInfo.getBanBieName(), pageStart, banBieInfo.getPageSize());
        if (banBies.size() == 0) {
            return Response.error2(StatusEnum.STAFF_NOT_EXIST2.getCode(), StatusEnum.STAFF_NOT_EXIST2.getMessage(), banBies);
        }
        HashMap<String, Object> res = new HashMap<>();
        res.put("banBieCounts", banBieCounts);
        res.put("data", banBies);
//        String YuanGong = JSON.toJSONString(res);
        return Response.success(res);
    }
}
